package com.bruce.springai.tools;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ai.tool.annotation.Tool;
import org.springframework.ai.tool.annotation.ToolParam;
import org.springframework.stereotype.Component;

import com.bruce.springai.dto.UserDTO;
import com.bruce.springai.dto.UserQueryDTO;
import com.bruce.springai.service.UserService;

import jakarta.annotation.Resource;

@Component
public class UserTools {

    private static final Logger logger = LoggerFactory.getLogger(UserTools.class);

    @Resource
    private UserService userService ;

    @Tool(description = "在查询用户信息之前，要求提供用户姓名、邮箱、电话号码。conversationId是聊天上下文的会话ID")
    String findUser(@ToolParam(description = "这个是聊天上下文的会话ID") String conversationId ,UserQueryDTO queryDTO){
      logger.info("conversationId:" + conversationId);
      UserDTO  userDTO = userService.findOne(queryDTO) ;
      if(userDTO == null){
          return "如果在系统中找不到该用户，请友好提示用户检查一下提供的信息是否正确" ;
      }
      return "返回查询结果" ;
    }

}
